<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="./bootstrap.css">
</head>
<body>
  <div id="app">
    <button>按钮</button>
    <btn text="按钮" type="danger" size="lg"></btn>
    <btn text="按钮" type="success" size="sm"></btn>
    <btn text="按钮" type="info" size="xs"></btn>
    <btn text="按钮" type="primary"></btn>
    <btn text="按钮" type="warning"></btn>



  </div>
  <script src="./vue.js"></script>
  <script>
    const btn = {
      template: `
        <button
          :class="typeClass"
        >
          {{text}}
        </button>
      `,
      props: ['text', 'type', 'size'],
      computed: {
        typeClass () {
          return ['btn', {
            'btn-danger': this.type==='danger', 
            'btn-success': this.type==='success',
            'btn-info': this.type==='info',
            'btn-primary': this.type==='primary',
            'btn-warning': this.type==='warning',
            'btn-sm': this.size === 'sm',
            'btn-lg': this.size === 'lg',
            'btn-xs': this.size === 'xs'
          }]
        }
      }
    }


    Vue.component('btn', btn)



    const app = new Vue({
      el: '#app'
    })
  
  </script>
</body>
</html>